package com.ctshk.common.enums;

import lombok.AllArgsConstructor;

import java.util.Arrays;

/**
 * 供应商付款类型
 */
public enum SupplierPaymentType {

    OPEN_ACCOUNT(1, "挂账"),
    PREPAYMENTS(2, "预付款"),
    ;

    private Integer code;
    private String name;

    SupplierPaymentType(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getEnumName(Integer code){
        SupplierPaymentType supplierPaymentType = Arrays.stream(SupplierPaymentType.values())
                .filter(enums -> enums.getCode().equals(code)).findFirst().orElse(null);
        if(supplierPaymentType != null){
            return supplierPaymentType.getName();
        }
        return "";
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}